﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/SystemManagement/Views/Shared/LigerUI.Master"
    Inherits="System.Web.Mvc.ViewPage<Zhuang.Model.EF.Sys_User>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <script src="/Scripts/MicrosoftAjax.js" type="text/javascript"></script>
    <script src="/Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>
    <script src="/Scripts/MicrosoftMvcValidation.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
        $(function () {
            $("#birthday").ligerDateEditor();
        });


        function onBegin() {
            if ($.trim($("#userName").val()) == "") {
                $.ligerDialog.warn("用户名不能为空！");
                return false;
            } else {
                return true;
            }

        }
        function submitSuccess(result) {
            if (result.get_data() == "0") {
                $.ligerDialog.success("用户名已经存在！");
            } else {
                parent.f_reload();
                parent.f_close();
            }
        }
        function submitFailure() {
            $.ligerDialog.error('保存失败！');
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <% ArrayList alGender = new ArrayList(); alGender.Add("男"); alGender.Add("女");%>
    <% 
        string action = "SaveUser";
        string onFailure = "submitFailure";
        string onSuccess = "submitSuccess";
        object userNameAtr = "disabled='disabled'" ;
        if (Model.UserId == -1)
        {

            userNameAtr = "";
            //action="SaveUser"
        }
        using (Ajax.BeginForm(new AjaxOptions() { Url = Url.Action(action, "User", new { area = "SystemManagement" }), HttpMethod = "Post", OnFailure = onFailure, OnSuccess = onSuccess, OnBegin = "onBegin" }))
        {
    %>
    <div>
        <input id="userId" name="userId" type="hidden" value="<%=Model.UserId %>" />
        <table cellpadding="10" cellspacing="10" align="center" style="border-collapse: separate;
            border-spacing: 10px;">
            <tr>
                <td>
                    用户名:
                </td>
                <td>
                   <input <%=userNameAtr%> id="userName" name="userName" type="text" value="<%= Model.UserName %>" />
                </td>
            </tr>
            <tr>
                <td>
                    <span>密码:</span>
                </td>
                <td>
                    <input id="password" name="password" type="password" value="<%=Model.Password %>" />
                </td>
            </tr>
            <tr>
                <td>
                    姓名:
                </td>
                <td>
                    <input type="text" id="name" name="name" value="<%=Model.Name %>" />
                </td>
            </tr>
            <tr>
                <td>
                    性别:
                </td>
                <td>
                    <select id="gender" name="gender">
                        <%if (Model.Gender.Trim() == "男")
                          {%>
                        <option value="男" selected="selected">男</option>
                        <option value="女">女</option>
                        <%}
                          else
                          {%>
                        <option value="男">男</option>
                        <option value="女" selected="selected">女</option>
                        <%} %>
                    </select>
                </td>
            </tr>
            <tr>
                <td>
                    出生年月:
                </td>
                <td>
                    <input type="text" name="birthday" id="birthday" value="<%=Model.Birthday %>" />
                </td>
            </tr>
            <tr>
                <td>
                    地址:
                </td>
                <td>
                    <textarea id="address" cols="20" name="address" rows="2"><%=Model.Address%></textarea>
                </td>
            </tr>
            <tr>
                <td>
                    <input type="submit" value="提交" style="width: 40px;" />
                </td>
                <td>
                    <input type="button" value="取消" onclick="parent.w.close()" style="width: 40px;" />
                </td>
            </tr>
        </table>
    </div>
    <%} %>

   
</asp:Content>
